
require 'growl'

module CcMonitor
  module BuildinActions
    def say(*something)
      content = something.flatten.join(" ").gsub(/\./, '. ').gsub(/"/, %{""})
      `/usr/bin/osascript -e "say \\"#{content}\\""`
    end

    def growl(*opt)
      title, desc, icon = opt.flatten
      GrowlApp.new.display title, desc, icon
    end

    def method_missing(method, *args)
      if method.id2name =~ /^let_([^_]+)_say/ && args.length > 0
        self.say(args[0], $1.gsub(/_/, ' '))
      else
        super
      end
    end
  end
end
